# _*_ coding: utf-8 _*_
__author__ = 'yinlei'
__date__ = '2018-05-24 20:20'

from urllib.parse import urlparse,urljoin
from flask import request

def is_safe_url(target):
    ref_url = urlparse(request.host_url)
    test_url = urlparse(urljoin(request.host_url,target))
    return test_url.scheme in ('http','https') and ref_url.netloc == test_url.netloc